package com.banban.user.controller;

import com.banban.user.domain.ConversationSummarize;
import com.banban.user.dto.UserProfileDTO;
import com.banban.user.service.ConversationSummarizeService;
import com.banban.user.vo.DataResult;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.validation.Valid;

@RestController
@RequestMapping("/summarize")
public class ConversationSummarizeController {

    @Autowired
    private ConversationSummarizeService conversationSummarizeService;

    @PostMapping("/getSummary")
    public DataResult getSummary(@RequestBody @Valid UserProfileDTO dto){
        String userId = dto.getUserId();
        QueryWrapper<ConversationSummarize> qw = new QueryWrapper<>();
        qw.eq("user_id",userId);
        qw.orderByAsc("create_time");
        return DataResult.success(conversationSummarizeService.list(qw));
    }

}
